USE [NANS21V]
GO

/****** Object:  UserDefinedFunction [dbo].[Basyo]    Script Date: 04/18/2014 18:12:09 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Basyo]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[Basyo]
GO

USE [NANS21V]
GO

/****** Object:  UserDefinedFunction [dbo].[Basyo]    Script Date: 04/18/2014 18:12:09 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[Basyo]
(
	@BASYO varchar
)
RETURNS VARCHAR(16)
AS
BEGIN
	
	DECLARE @return varchar(16)
	
	select @return = MSG.TITLE from TBL_WEB_USE_ID ID,TBL_WEB_USE_MSG MSG
	WHERE LOWER(TAGNAME)=LOWER('EventPlaces') 
	AND ID.TAGID=MSG.TAGID
	AND MSG.XMLCODE=@BASYO
	
	RETURN @return
/*
	IF @BASYO = '0'
		SET @return = 'トラック'
	ELSE IF @BASYO = '1'
		SET @return = 'メイン'
	ELSE IF @BASYO = '2'
		SET @return = 'バック'
	ELSE IF @BASYO = '3'
		SET @return = 'Aゾーン'
	ELSE IF @BASYO = '4'
		SET @return = 'Bゾーン'
	ELSE IF @BASYO = '5'
		SET @return = '投てき場'
	ELSE IF @BASYO = '6'
		SET @return = 'サブ競技場'
	ELSE IF @BASYO = '7'
		SET @return = '道路競技'
	ELSE 
		SET @return = ''
*/
	
END
GO

